﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using OASys.Web.Base;
using OASys.Entity;
using Project.Common;
using OASys.Biz.BizAccess;
using OASys.Enum;
using OASys.Entity.EntitySearch;
using Project.Entity.Base;
using Project.Web.Base.Utility;

namespace OASys.Web.Areas.ModuleSys.Models
{
    public class ModelWorkDayDateDiff 
    {
    }
    /// <summary>
    /// 工作日设定
    /// 作者：尤啸
    /// 时间：2012-05-25
    /// </summary>
    public class ModelWorkDayDateDiffIndex : BaseModel
    {
        private BizUVSysWorkDaysSetting bizUVSysWorkDaysSetting;
        /// <summary>
        /// 查询设置排序列名,倒/顺序
        /// </summary>
        private BaseSearch searchEntity;
        public BaseSearch SearchEntity
        {
            get
            {
                if (searchEntity == null)
                    searchEntity = new BaseSearch();
                if (string.IsNullOrEmpty(searchEntity._OrderName))
                {
                    searchEntity._OrderName = ReflectionTools.GetPropertyNameFromExpression<UVSysWorkDaysSetting>(x => x.YearMonth);
                    searchEntity._OrderDirection = ((int)EnumOrder.DESC).ToString();
                }
                return searchEntity;                
            }
            set 
            {
                searchEntity = value;
            }
        }
        /// <summary>
        /// 集合
        /// </summary>
        IList<UVSysWorkDaysSetting> uVSysWorkDaysSettingCollection = new List<UVSysWorkDaysSetting>();
        /// <summary>
        /// 系统工作日设定
        /// </summary>
        public IList<UVSysWorkDaysSetting> UVSysWorkDaysSettingCollection
        {
            get { return uVSysWorkDaysSettingCollection; }
            set { uVSysWorkDaysSettingCollection = value; }
        }
        /// <summary>
        /// 检索数据
        /// </summary>
        public void RetriveData()
        {
            //多条件查询实例
            ExpressionCondition<UVSysWorkDaysSetting> uvCondition =   
                ExpressionCondition<UVSysWorkDaysSetting>.GetInstance();
            if (!string.IsNullOrEmpty(SearchEntity._CommonSearchCondition))
            {
                uvCondition.Or(x => x.YearMonth, SearchEntity._CommonSearchCondition, 
                    ExpressionValueRelation.Like);
            }
            //给集合赋值
            UVSysWorkDaysSettingCollection = bizUVSysWorkDaysSetting.PaginateListBy(
                SearchEntity._PageSize.Value,
                SearchEntity._PageIndex ?? 0,
                ref count,
                uvCondition.ConditionExpression,
                SearchEntity._OrderName,
                SearchEntity.EnumOrderDirection);

            PaginateHelperObject = PaginateHelper.ConstructPaginate(
                SearchEntity._PageSize.Value,
                count,
                SearchEntity._PageIndex ?? 0,
                SearchEntity,
                "SearchEntity");                                                   
        }
    }

    public class ModelWorkDayDateDiffCreate : BaseModel
    {
        /// <summary>
        /// 页面状态
        /// </summary>
        public EnumPageState? PageState { get; set; }

        /// <summary>
        /// 要显示的年份
        /// </summary>
        public  DateTime? Date { get; set; }
        /// <summary>
        /// 检索日期
        /// </summary>
        public void RetriveDate()
        {
            Date = Date == null ? DateTime.Now : Date.Value;
        }


    }
}